package com.yd.tbk.Controller;

import com.taobao.api.ApiException;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.request.TbkItemInfoGetRequest;
import com.taobao.api.response.TbkItemInfoGetResponse;
import com.yd.tbk.common.Taobao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @Auther: danielyu
 * @Date: 2018/9/8 21:48
 * @Description:
 */
@Controller
@RequestMapping(value = "tb")
public class TaobaoController {

    private Logger logger = LoggerFactory.getLogger(TaobaoController.class);

    @ResponseBody
    @GetMapping("/item/info/get")
    public String returnModel(HttpServletRequest request) throws ApiException {

        DefaultTaobaoClient client = new DefaultTaobaoClient(Taobao.url, Taobao.appKey, Taobao.appSecret);
        TbkItemInfoGetRequest req = new TbkItemInfoGetRequest();
        req.setNumIids("575237909650");
        req.setPlatform(2L);
        TbkItemInfoGetResponse rsp = client.execute(req);
        System.out.println(rsp.getBody());
        return rsp.getBody();
    }
}
